﻿using System;
using System.DirectoryServices;

namespace zielonka.co.uk.extensions.system.directoryservices
{
    // Description:	extensions that work with SearchResult to retrieve its data.
    /*
        result.GetValue("sAMAccountName", String.Empty)
     */

    public static partial class SearchResultExtensions
    {
        public static Guid? GetObjectGuid(this SearchResult result)
        {
            if (result.Properties["objectGuid"].Count == 1)
            {
                var b = (byte[])result.Properties["objectGuid"][0];
                return new Guid(b);
            }

            return null;
        }
    }
}
